﻿function GetPathName() {
    var pathname = window.location.pathname;
    if (pathname.indexOf("/", 2) > 0) return pathname.substring(0, pathname.indexOf("/", 2));
    else
        return pathname.substring(0, pathname.indexOf("/", 1)) + "";
}

function GetQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) return unescape(r[2]); return null;
}

function blockUI() {
    $.blockUI({
        message: '<img src="../images/load.gif" /> <h1>Please Wait...</h1>',
        css: { border: '3px solid #FB7902', color: '#888', padding: '10px 20px' }
    });
}
//利用Bootstrap自带浮动框生成页面加载提示
function showLoading() {
    $('#myModal').modal({
        keyboard: true,
        backdrop: "static"
    })
}
function closeLoading() {
    $('#myModal').modal("hide");
}

//ajax get data demo
function testAjax() {
    return;
    $.ajax({
        url: GetPathName() + "/Home/GetCurrentUser/",
        data: {
            orderId: 1,
            instanceId: 0
        },
        dataType: "json",
        success: function (result) {
            $("#username").html('Welcome,' + result.StaffName);
        },
        error: function () {

        }
    });
}

//常用
//JSON.parse(jsonstr); //可以将json字符串转换成json对象 
//JSON.stringify(jsonobj); //可以将json对象转换成json对符串